﻿package mortal.game.view.lookPlayerInfo.view
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.gengine.core.frame.*;
    import flash.events.*;
    import frEngine.pools.*;
    import mortal.component.window.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.common.*;

    public class LookFashionInfoPanel extends LookSystemBasePanel
    {
        protected var _roleModelPlayer:UserModelPlayer;

        public function LookFashionInfoPanel(param1:Window)
        {
            super(param1);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            if (_rect3d && this._roleModelPlayer)
            {
                _rect3d.disposeObj3d(this._roleModelPlayer);
                this._roleModelPlayer = null;
            }
            super.disposeImpl(param1);
            return;
        }// end function

        override protected function update3DModel() : void
        {
            var _loc_1:SMiniPlayer = null;
            var _loc_2:ItemEquipInfo = null;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:Boolean = false;
            var _loc_10:Boolean = false;
            var _loc_11:Boolean = false;
            var _loc_12:SPlayerItem = null;
            var _loc_13:int = 0;
            if (_rect3d)
            {
                _loc_1 = _sLookPlayerInfo.miniPlayer;
                if (this._roleModelPlayer == null)
                {
                    this._roleModelPlayer = FrObjectPool.getObject(UserModelPlayer, this);
                }
                _loc_3 = _loc_1.career;
                _loc_4 = _loc_1.sex;
                _loc_6 = 0;
                _loc_7 = 0;
                _loc_8 = _loc_1.VIP;
                if (_lookType == ELookUpType._ELookUpTypeFashion)
                {
                    if (_slookPlayerMountInfo.shape > 10)
                    {
                        _loc_5 = (ItemConfig.instance.getConfig(_slookPlayerMountInfo.shape) as ItemEquipInfo).modelId;
                    }
                    else
                    {
                        _loc_5 = _tmountInfo.modelId;
                    }
                }
                else if (_lookType == ELookUpType._ELookUpTypeWings)
                {
                    for each (_loc_12 in _sLookPlayerInfo.playerItems)
                    {
                        
                        _loc_2 = ItemConfig.instance.getConfig(_loc_12.itemCode) as ItemEquipInfo;
                        if (_loc_5 == 0 && _loc_2.type == EEquip._EEquipClothes)
                        {
                            _loc_5 = int(_loc_2.modelId);
                        }
                    }
                    _loc_13 = this.getClothesModelId();
                    if (_loc_13 > 0)
                    {
                        _loc_5 = _loc_13;
                    }
                    if (_sLookPlayerInfo.wingCode > 1000)
                    {
                        _loc_2 = ItemConfig.instance.getConfig(_sLookPlayerInfo.wingCode) as ItemEquipInfo;
                        _loc_7 = _loc_2.modelId;
                    }
                    else
                    {
                        _loc_7 = _tmountInfo.modelId;
                    }
                }
                _loc_9 = _sLookPlayerInfo.wingCode > 10000;
                _loc_10 = _sLookPlayerInfo.clothesCode > 10000;
                _loc_11 = _sLookPlayerInfo.weaponCode > 10000;
                this._roleModelPlayer.updateIsShowEffect(_loc_11, _loc_10, _loc_9);
                this._roleModelPlayer.updateInfo(_loc_3, _loc_4, _loc_5, 0, 0, _loc_7, _loc_8);
                this._roleModelPlayer.useLight();
                this.reset3dModelPos();
            }
            return;
        }// end function

        private function getClothesModelId() : int
        {
            var _loc_1:int = 0;
            var _loc_2:ItemEquipInfo = null;
            var _loc_3:TMountConfig = null;
            if (_sLookPlayerInfo.clothesCode > 10000)
            {
                _loc_2 = ItemConfig.instance.getConfig(_sLookPlayerInfo.clothesCode) as ItemEquipInfo;
                _loc_1 = _loc_2 ? (_loc_2.modelId) : (0);
            }
            else
            {
                _loc_3 = MountConfig.instance.getFashionInfoByCode(EAdvanceComponentType._EAdvanceComponentTypeClothes, _sLookPlayerInfo.clothesCode);
                _loc_1 = _loc_3 ? (_loc_3.modelId) : (0);
            }
            return _loc_1;
        }// end function

        override protected function reset3dModelPos(param1:TModel = null) : void
        {
            this._roleModelPlayer.scaleAll = 2.3;
            _rect3d.addObject3d(this._roleModelPlayer, 73 + 72 + 94, 133 + 223 + 20 + 20);
            return;
        }// end function

        override protected function addOtherObj() : void
        {
            var _loc_1:String = null;
            if (_lookType == ELookUpType._ELookUpTypeFashion)
            {
                _loc_1 = ImagesConst.Fashion_ClothSkillText;
            }
            else if (_lookType == ELookUpType._ELookUpTypeWings)
            {
                _loc_1 = ImagesConst.Fashion_WingSkillText;
            }
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(_loc_1, 212 + 4 + 3, 429 + 32, _window.contentTopOf3DSprite));
            return;
        }// end function

        override protected function onClickTurnBtn(event:MouseEvent) : void
        {
            if (this._roleModelPlayer)
            {
                if (event.currentTarget == _leftBtn)
                {
                    turnValue = 2;
                }
                if (event.currentTarget == _rightBtn)
                {
                    turnValue = -2;
                }
                start();
            }
            return;
        }// end function

        override protected function onTurning(param1:FrameTimer) : void
        {
            if (this._roleModelPlayer)
            {
                this._roleModelPlayer.rotationY = this._roleModelPlayer.rotationY + turnValue;
            }
            return;
        }// end function

        override protected function turning(event:MouseEvent) : void
        {
            _endX = this.mouseX;
            if (this._roleModelPlayer)
            {
                this._roleModelPlayer.rotationY = this._roleModelPlayer.rotationY - (_endX - _startX) / 3;
            }
            _startX = _endX;
            return;
        }// end function

    }
}
